home *** CD-ROM | disk | FTP | other *** search
- unit PaintBMP;
-
- interface
-
- uses Strings, WinTypes, WinProcs, WObjects;
-
- {$R PAINTBMP.RES}
-
- const
- br_Check = 1;
- br_Blank = 0;
-
- type
- PWinBMP = ^TWinBMP;
- TWinBMP = object( TWindow)
- TheBrush : HBrush;
- WinX, WinY,
- WinH, WinW : integer;
- DC : HDC;
-
- constructor Init( AParent: PWindowsObject; ATitle: PChar; x1, y1, h1, w1: integer; St: longint);
- destructor Done; virtual;
- procedure MakeBrush( Brush: integer); virtual;
- procedure PaintCheck; virtual;
- procedure PaintBlank( x1, y1, x2, y2: integer); virtual;
- procedure ShadowFrame( x1, y1, x2, y2: integer); virtual;
- procedure ShadowHLine( x1, x2, y1: integer); virtual;
- procedure ShadowVLine( x1, y1, y2: integer); virtual;
- end;
-
- implementation
-
- constructor TWinBMP.Init( AParent: PWindowsObject; ATitle: PChar; x1, y1, h1, w1: integer; St: longint);
- begin
- TWindow.Init( AParent, ATitle);
-
- WinX := 0;
- WinY := 0;
- WinH := h1;
- WinW := w1;
-
- Attr.Style := St;
- Attr.X := x1;
- Attr.Y := y1;
- Attr.H := h1 - 1;
- Attr.W := w1 - 1;
-
- Create;
- DC := GetDC( HWindow);
- PaintCheck;
- end;
-
- destructor TWinBMP.Done;
- begin
- TWindow.Done;
- ReleaseDC( HWindow, DC);
- end;
-
- procedure TWinBMP.MakeBrush( Brush: integer);
- var
- MyLogBrush: TLogBrush;
- TheBitMap : HBitMap;
- begin
- case Brush of
- br_Check: TheBitMap := LoadBitMap( HInstance, 'CHECKS8X8');
- br_Blank: TheBitMap := LoadBitMap( HInstance, 'BLANK8X8');
- end;
- MyLogBrush.lbStyle := bs_Pattern;
- MyLogBrush.lbHatch := TheBitMap;
- TheBrush := CreateBrushIndirect( MyLogBrush);
- DeleteObject( TheBitMap);
- end;
-
- procedure TWinBMP.ShadowFrame( x1, y1, x2, y2: integer);
- var
- P1, P2: HPen;
- begin
- P2 := CreatePen( ps_Solid, 1, $00808080);
- P1 := GetStockObject( White_Pen);
-
- MoveTo( DC, x1, y2);
- SelectObject( DC, P1);
- LineTo( DC, x2, y2);
- LineTo( DC, x2, y1);
-
- SelectObject( DC, P2);
- LineTo( DC, x1, y1);
- LineTo( DC, x1, y2);
-
- DeleteObject( P1);
- DeleteObject( P2);
- end;
-
- procedure TWinBMP.ShadowHLine( x1, x2, y1: integer);
- var
- P1, P2: HPen;
- begin
- P2 := CreatePen( ps_Solid, 1, $00808080);
- P1 := GetStockObject( White_Pen);
-
- SelectObject( DC, P2);
- MoveTo( DC, x1, y1);
- LineTo( DC, x2, y1);
-
- SelectObject( DC, P1);
- MoveTo( DC, x2, y1+1);
- LineTo( DC, x1, y1+1);
-
- DeleteObject( P1);
- DeleteObject( P2);
- end;
-
- procedure TWinBMP.ShadowVLine( x1, y1, y2: integer);
- var
- P1, P2: HPen;
- begin
- P2 := CreatePen( ps_Solid, 1, $00808080);
- P1 := GetStockObject( White_Pen);
-
- SelectObject( DC, P2);
- MoveTo( DC, x1, y1);
- LineTo( DC, x1, y2);
-
- SelectObject( DC, P1);
- MoveTo( DC, x1+1, y2);
- LineTo( DC, x1+1, y1);
-
- DeleteObject( P1);
- DeleteObject( P2);
- end;
-
- procedure TWinBMP.PaintCheck;
- var
- MyRect: TRect;
- begin
- MakeBrush( br_Check);
- SelectObject( DC, TheBrush);
- MyRect.left := WinX;
- MyRect.top := WinY;
- MyRect.right := WinW;
- MyRect.bottom := WinH;
- FillRect( DC, MyRect, TheBrush);
- DeleteObject( TheBrush);
- end;
-
- procedure TWinBMP.PaintBlank( x1, y1, x2, y2: integer);
- var
- MyRect: TRect;
- begin
- MakeBrush( br_Blank);
- SelectObject( DC, TheBrush);
- MyRect.left := x1;
- MyRect.top := y1;
- MyRect.right := x2;
- MyRect.bottom := y2;
- FillRect( DC, MyRect, TheBrush);
- DeleteObject( TheBrush);
- end;
-
- end.